package coms.process;

import java.util.Map;
import com.beans.AccountingPoolGroupUserBean;
import com.crc.mam.BaseCase;
import coms.AutoException;
import coms.Constants;
import frame.FrameWork;
import frame.InterTest;
import functions.ems_accountant_job_pool.Pool;
import functions.mams_rest.User;

public class AccountingPoolProcess extends BaseCase implements InterTest{
	String claimNo;
	int actId;
	
	public int getActId() {
		return actId;
	}

	public void setActId(int actId) {
		this.actId = actId;
	}
	
	public String getClaimNum() {
		return claimNo;
	}

	public void setClaimNum(String claimNum) {
		this.claimNo = claimNum;
	}


	/**
	 * 入参：claimNum， actId (1为核算会计，2为复核会计)
	 */
	@Override
	public void run(Map<Object, Object> paramMap) {
		// TODO Auto-generated method stub
	  String baseUrl = (String) paramMap.get("baseUrl");
      if(baseUrl !=null) {
        FrameWork.setBaseUrl(baseUrl);
      }

	      LoginTest loginTest = new LoginTest();
	      loginTest.run(paramMap);
	      if(!loginTest.status) {
	        remark = loginTest.result;
	        status = false;
	        throw new AutoException("登录失败，阻碍测试");
	      }
	
      String claimNo = (String) paramMap.get("claimNo");
      String actId = (String) paramMap.get("actId");
      Pool pool = new Pool(claimNo,Integer.valueOf(actId));
      pool.list();
      if(pool.status) {
        pool.grouping();
        if(pool.status) {
          pool.unassignedList();
          if(pool.status) {
            String groupId = (String) paramMap.get("groupId");
            pool.assigning(groupId);
            if(pool.status) {
              AccountingPoolGroupUserBean accountAuditUser = pool.getAccountAuditUser();
              if(accountAuditUser !=null) {
                paramMap.put("userCode", accountAuditUser.getCrewEmpCode());
                LoginTest login = new LoginTest();
                login.run(paramMap);
                if(login.status) {
                  Todo todo = new Todo();
                  todo.run(paramMap);
                  if(todo.status) {
                    status = true;
                  }else {
                    status = false;
                    remark = "任务池监控失败： " + todo.remark;
                  }
                }else {
                  status = false;
                  remark = "任务池监控失败： " + login.remark;
                }
               
              }else {
                status = false;
                remark = "任务池监控失败： " + pool.remark;
              }
            }else {
              status = false;
              remark = "任务池监控失败： " + pool.remark;
            }
          }else {
            status = false;
            remark = "任务池监控失败： " + pool.remark;
          }
        }else {
          status = false;
          remark = "任务池监控失败： " + pool.remark;
        }
      }else {
        status = false;
        remark = "任务池监控失败： " + pool.remark;
      }
      
	}

  @Override
  public boolean getStatus() {
    // TODO Auto-generated method stub
    return false;
  }

  @Override
  public String getRemark() {
    // TODO Auto-generated method stub
    return null;
  }

}
